home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Print_Master_to_TypeSetter;
-
- { PM2TS - a graphics utility }
- { by }
- { David W Binnion }
- { Delphi - D_W_B CompuServe - 76515, 1571 }
- { }
- { converts Print Master (tm) icons to Type Setter (tm) icons }
- { in monochrome format. }
- { 07-29-86 }
- { }
- { Portions of this product are Copyright (c) 1986, by OSS }
- { and CCD. Used by permission of OSS. }
- { }
- { I'd like to run this is medium res too but I don't }
- { have access to a color monitor. Out in the sticks }
- { where I live IBM is God and Atari a pimple on his }
- { CPU. Feel free to modify this to your liking and }
- { leave a message if you upgrade it to color. I'd }
- { be pleased to see it. }
-
- CONST
-
- {$I GEMCONST.PAS}
-
- TYPE
-
- str88 = STRING[88];
- str16 = STRING[16];
- chr16 = PACKED ARRAY [1..16] OF CHAR;
- chr2 = PACKED ARRAY [ 1..2 ] OF CHAR;
- path_chars = PACKED ARRAY [1..80] OF CHAR;
-
- {$I gemtype.pas}
-
- VAR window_number : INTEGER;
-
- {$I gemsubs}
-
-
- PROCEDURE good_bye;
-
- VAR message : STRING;
- choice : INTEGER;
-
- BEGIN
- message := '[0][Thanks for using ';
- message := CONCAT( message , '| PM2TS' );
- message := CONCAT( message , '|---------------- ' );
- message := CONCAT( message , '| D_W_B]' );
- message := CONCAT( message , '[ goodbye! ]' );
- choice := Do_Alert( message, 1 );
-
- END; { vanity1 }
-
-
- PROCEDURE Vanity1;
-
- VAR message : STRING;
- choice : INTEGER;
-
- BEGIN
- message := '[0][ PM2TS (c)...by';
- message := CONCAT( message , '| D_W_B - Delphi' );
- message := CONCAT( message , '| 76515,1571 - CompuServe|]' );
- message := CONCAT( message , '[ go ]' );
- choice := Do_Alert( message, 1 );
-
- END; { vanity1 }
-
-
- PROCEDURE Vanity2;
-
- VAR message : STRING;
- choice : INTEGER;
-
- BEGIN
- message := '[3][| Portions of this ';
- message := CONCAT( message , '| product are ');
- message := CONCAT( message , '| Copyright (c), ]');
- message := CONCAT( message , '[ 1986 ]' );
- choice := Do_Alert( message, 1 );
-
- END; { vanity2 }
-
-
- PROCEDURE Vanity3;
-
- VAR message : STRING;
- choice : INTEGER;
-
- BEGIN
- message := '[1][| by OSS and CCD. Used ';
- message := CONCAT( message , '| by permission of OSS. ]');
- message := CONCAT( message , '[ okay! ]' );
- choice := Do_Alert( message, 1 );
-
- END; { vanity3 }
-
-
- PROCEDURE Vanity;
-
- BEGIN
- vanity1;
- vanity2;
- vanity3;
- END;
-
-
- PROCEDURE Clean_Window;
-
- VAR x, y, h, w : INTEGER;
-
- BEGIN
- Hide_Mouse;
- Work_Rect( window_number, x, y, h, w );
- Set_Clip( x, y, h, w);
- Paint_Color( white );
- Paint_Style( 1 );
- Paint_Rect( x, y, h, w );
- Paint_Color( black );
- Show_Mouse;
-
- END; { Clean_Window }
-
-
- PROCEDURE Screen_Set_Up( VAR window_number : INTEGER);
-
- VAR x, y, h, w : INTEGER;
- title : Window_Title;
- info : path_name;
-
- BEGIN
- title := ' Print Master to TypeSetter ';
- window_number := New_Window( G_name | G_Info , title, 0,0,0,0);
- Hide_Mouse;
- info := ' ';
- Set_WInfo( window_number , info );
- Open_Window( window_number, 0,0,0,0);
- Work_Rect( window_number, x, y, h, w );
- Set_Clip( x, y, h, w );
- Clean_Window;
- Text_color( black );
- Line_Color( black );
- Draw_Mode( 1 );
- Line_Style( 1 );
- Show_Mouse;
-
- END; { screen_set_up }
-
-
- FUNCTION f_write( handle : INTEGER; count : LONG_INTEGER;
- VAR buf : chr2 ) : LONG_INTEGER;
- GEMDOS( $40 );
-
-
- FUNCTION f_create( VAR f_name : path_chars;
- attributes : INTEGER) : INTEGER;
- GEMDOS( $3c );
-
-
- FUNCTION f_open( VAR o_name : path_chars; mode : INTEGER ) : INTEGER;
- GEMDOS( $3d );
-
-
- FUNCTION f_read( handle : INTEGER; count : LONG_INTEGER;
- VAR buf : chr16 ) : LONG_INTEGER;
- GEMDOS( $3f);
-
-
- FUNCTION f_seek( offset : LONG_INTEGER; handle, mode : INTEGER )
- : LONG_INTEGER;
- GEMDOS( $42 );
-
- FUNCTION f_close( handle : INTEGER ) : INTEGER;
- GEMDOS( $3e);
-
-
- PROCEDURE Make_Pathname( VAR pn : path_chars; fn : path_name );
-
- VAR i : INTEGER;
-
- BEGIN
-
- FOR i := 1 to length( fn ) DO { pathname must be held }
- pn[ i ] := fn[ i ]; { in character array so }
- pn[ length( fn ) + 1 ] := fn[ 1 ]; { transfer from string }
-
- END; { make_pathname }
-
-
- PROCEDURE Main_Routine;
-
- VAR icon_PM : chr2;
- icon_TS : char;
- name_PM : chr16;
- in_path, out_path, in_filename, out_filename : Path_Name;
- icon_name : str16;
- icon : ARRAY [1..53] OF str88;
- good_name, quit : BOOLEAN;
- misc1, misc2 : INTEGER;
- PM_Name_handle , PM_Data_handle , TS_Data_Handle,
- m_error : INTEGER;
-
-
- PROCEDURE Initialize_Variables;
-
- BEGIN
- in_filename := ''; { make certain in_filename and }
- in_path := 'A:\*.SDR'; { out_filename are clear of }
- out_path := 'A:\*.ICN'; { extraneous characters & }
- out_filename := ''; { set up pathnames. }
-
- END; { iniatialize_variables }
-
-
- PROCEDURE Get_PM_Name;
-
- VAR start, finish : INTEGER;
-
- BEGIN
- IF POS( '.SDR' , in_path ) = 0 THEN { wrong pathname? }
- BEGIN
- start := Pos( '.' , in_path ); { strip off extender & }
- finish := ( length( in_path ) - start ) + 1; { put on .SDR }
- delete( in_path, start , finish );
- in_path :=Concat( in_path, '.SDR' );
- END;
- good_name := Get_In_File( in_path, in_filename );
- Clean_Window;
-
- END; { get_pm_name }
-
-
- PROCEDURE Get_TS_Name;
-
- VAR start, finish : INTEGER;
-
- BEGIN
- IF POS( '.ICN' , out_path ) = 0 THEN
- BEGIN
- start := Pos( '.' , out_path ); { strip off extender & }
- finish := ( length( out_path ) - start ) + 1; { put on .ICN }
- delete( out_path, start , finish );
- out_path :=Concat( out_path, '.ICN' );
- END;
- good_name := Get_In_File( out_path, out_filename );
-
- END; { get_TS_name }
-
-
- PROCEDURE Open_PM_File( VAR error : INTEGER );
-
- VAR filename : path_chars;
-
- BEGIN
- Make_Pathname( filename , in_filename );
- error := f_open( filename , 0 );
- PM_Name_handle := error;
-
- END; { open_pm_file }
-
-
- PROCEDURE Open_PM_Data( VAR error : INTEGER );
-
- VAR start, finish : INTEGER;
- filename : path_chars;
- temp_filename : Path_Name;
-
- BEGIN
- temp_filename := in_filename; { save in_filename }
- start := Pos( '.' , in_filename ); { strip off extender & }
- finish := ( length( in_filename ) - start ) + 1; { put on .SHP }
- delete( in_filename, start , finish );
- in_filename :=Concat( in_filename, '.SHP' );
- Make_Pathname( filename , in_filename );
- error := f_open( filename , 0 );
- PM_Data_Handle := error;
- in_filename := temp_filename; { restore original name }
-
- END; { open_PM_Data }
-
-
- PROCEDURE Open_TS_Data( VAR error : INTEGER );
-
- VAR filename : path_chars;
-
- BEGIN
- Make_Pathname( filename , out_filename );
- error := f_create( filename , 0 ); { error actually the }
- TS_Data_Handle := error; { pathnumber }
-
- END; { open_TS_Data }
-
-
- PROCEDURE Confirm_Quit;
-
- VAR message : str88;
- choice : INTEGER;
-
- BEGIN
- message := '[3][ Confirm your | desire to quit. ][ quit | continue ]';
-
- choice := Do_Alert( message, 1 );
-
- IF choice = 1 THEN
- BEGIN
- quit := TRUE; { if quit then flags must }
- good_name := TRUE; { be altered to reflect }
- END
- ELSE
- quit := FALSE;
-
- END; { confirm_quit }
-
-
- PROCEDURE Bad_Name( cfile : Path_Name );
-
- VAR message : STRING;
- choice : INTEGER;
-
- BEGIN
-
- message := concat( '[1][ ', cfile ) ;
- message := concat( message , '| is invalid. ');
- message := concat( message , '| Do you wish to: ]');
- message := concat( message , '[ quit | retry ]');
-
- choice := Do_Alert( message, 1 );
-
- If choice = 1 THEN { If quit chosen must change both }
- BEGIN { flags so can drop out of two }
- good_name := TRUE; { different WHILE loops. }
- quit := TRUE;
- END
-
- END; { bad_name }
-
-
- PROCEDURE Check_Name( extender : path_name ; VAR name : path_name;
- VAR no_error : BOOLEAN );
-
- VAR i , j , k : INTEGER;
-
- BEGIN
- no_error := TRUE;
- k := 1; { make certain filename has }
- i := length( name ); { something in it! & starts }
- j := Pos( '.' , name ); { with a letter }
- IF ( i = 0 ) OR ( name[ 1 ] < 'A' ) THEN
- good_name := FALSE { otherwise make }
- ELSE { good_name FALSE. }
- IF j = 0 THEN { no extender so add it }
- BEGIN
- name := CONCAT( name , '.' ); { add period & }
- name := CONCAT( name , extender ); { extender }
- END
- ELSE { has extender so check it }
- FOR i := j + 1 TO j + 3 DO
- BEGIN
- if name[ i ] <> extender[ k ] THEN { do extenders match ? }
- no_error := FALSE; { nope! }
- k := k + 1;
- END;
- IF no_error = FALSE THEN { an illegal name found }
- bad_name( name ); { alert & get action }
-
- END; { check_name }
-
-
- PROCEDURE Menu;
-
- VAR let_x, let_y, pos_x, pos_y : INTEGER; { for printing icon names }
- icon_offset, max_icons, { icon number & menu offset }
- choice, old_choice : INTEGER;
- names : ARRAY [1..32] OF str16;
- eof, made_choice, done, pop_event : BOOLEAN;
- ch_real : real;
- tempr_str : string;
- tempt_str : string;
-
-
- PROCEDURE Print_Menu_Title;
-
- VAR info : path_name;
- i : INTEGER;
-
- BEGIN
- Clean_Window;
- hide_mouse;
- info := ' ';
- FOR i := 1 to (79 - length( in_filename ) ) DIV 2 DO
- info := concat( info , ' ' );
- info := concat( info , in_filename );
- delete( info , pos( '.' , info ) , 4 );
- Set_WInfo( window_number , info );
- Text_Style( Underlined | Thickened );
- Draw_String( 26 * let_x, 21 * let_y,' Click Left Button To Choose ');
- Text_Style( Normal );
- line_color( black );
- line_style( 1 ); { solid line }
- Frame_Rect( let_x * 31 + 3 , let_y * 4 + 9 ,
- let_x * 12 + 4 , let_y * 5 - 11 );
- show_mouse;
-
- END; { print_menu_title }
-
-
- PROCEDURE Get_30_Names( VAR number : INTEGER);
-
- { gets 30 names from file or as many as are left }
-
- VAR temp_Char : chr16;
- s_error , r_error : LONG_INTEGER;
- temp_str : str16;
- i : INTEGER;
- found_char : BOOLEAN;
-
- BEGIN
- if eof = TRUE THEN { the last screen found end of file }
- BEGIN { so cycle back to first set of }
- icon_offset := 0; { names and set flag to FALSE. }
- eof := FALSE;
- END;
- number := 0; { number of names read }
- s_error := 0; { offset in bytes from start of file }
- r_error := 10; { number of bytes read from file }
-
- WHILE ( s_error >= 0 ) AND ( number < 30 ) AND
- ( icon_offset + number < 114 ) AND ( r_error <> 0 ) DO
-
- { due to some error I haven't found, can only read the icon data }
- { files for the first 113 icons. After that get a read error }
-
- BEGIN
- s_error := f_Seek( (icon_offset + number) * 16,
- PM_Name_handle, 0 );
- r_error := f_read( PM_Name_handle , 16 , temp_char );
- IF ( r_error = 16 ) AND ( s_error >= 0 ) THEN
- BEGIN { good read so }
- temp_str := ' '; { give temp_str }
- FOR i := 1 to 16 DO { a length and }
- temp_str[ i ] := temp_char[ i ]; { move from }
- { buffer to temp }
-
- { IMPORTANT!! Strings must be read into a CHAR ARRAY and then }
- { moved over manually into the string. Trying to read a string }
- { directly causes all kinds of grief because 1st char winds up }
- { in 0th cell of string which contains the length of a string! }
-
- number := number + 1; { incr number }
- names[ number ] := temp_str; { put into array }
- END { if }
- ELSE
- eof := TRUE; { if had a read error, set }
- { eof to true. }
- END; { while }
-
- IF (number = 0) OR { last screen or last # }
- ( icon_offset + number > 113 ) THEN { was 113 during read. }
- eof := TRUE; { set eof true. }
-
- names[ number + 1 ] := 'Next Screen '; { two prompts added }
- names[ number + 2 ] := 'Quit '; { so they'll print }
- choice := number + 1; { puts cursor on }
- { next screen choice }
- END; { get_30_names }
-
-
- PROCEDURE Get_Coordinates( wich : INTEGER );
-
- BEGIN
- pos_x := 5; { 1st column at 5 }
- pos_y := wich + 5; { 5 + # of choice }
- { y = ( 6 to 18 ) }
- IF wich > 13 THEN { chose # > 13 ? }
- BEGIN { if so, start 2nd }
- pos_x := 32; { column at 32 }
- pos_y := wich - 3; { choice - 3 }
- END; { short column }
- { y = ( 11 - 18 ) }
- IF wich > 21 THEN { # chose > 21 ? }
- BEGIN { column 3 at 57 }
- pos_x := 57; { y = ( 6 to 16 ) }
- pos_y := wich - 16;
- END;
-
- pos_x := pos_x * let_x; { mult x & y positions to get }
- pos_y := pos_y * let_y; { dot offsets }
-
- END; { get_coordinates }
-
-
- PROCEDURE Print_30_Names( number : INTEGER );
-
- VAR tempr : INTEGER;
- temp_str : str16;
-
- BEGIN
- hide_mouse;
- tempr := 1;
-
- FOR tempr := 1 TO number + 2 DO { number of icon names read }
- BEGIN { plus 2 more to print the }
- Draw_Mode( 1 ); { next screen and quit opts }
- Text_Color( 1 );
- Get_Coordinates( tempr ); { get dot co-ords for drawing }
- Draw_String( pos_x, pos_y, names[ tempr ]);
- END;
- show_mouse;
-
- END; { print_30_names }
-
-
- PROCEDURE Get_Choice( VAR choice_made : BOOLEAN );
-
- VAR message : MESSAGE_BUFFER;
- which1, dummy, mx, my, button, count : INTEGER;
- Tempr_Str : Str16;
-
-
- PROCEDURE Evaluate_Choice;
-
- VAR x, y, temp : INTEGER;
-
- BEGIN
- x := ( mx DIV let_x ) ; { get adjusted x and y co-ords }
- y := ( my DIV let_y ) + 1;
- old_choice := choice; { save choice }
- choice := 0;
-
- IF ( x > 4 ) AND ( x < 20 ) THEN { column 1 }
- BEGIN
- temp := y - 5; { y = 6 - 18 }
- IF ( temp > 0 ) AND ( temp < 14 ) THEN
- choice := temp;
- END;
- IF ( x > 31 ) AND ( x < 47 ) THEN { column 2 }
- BEGIN
- temp := y + 3; { y = 11 - 18 }
- IF ( temp > 13 ) AND ( temp < 22 ) THEN
- choice := temp;
- END;
- IF ( x > 56 ) AND ( x < 72 ) THEN { column 3 }
- BEGIN
- temp := y + 16; { y = 6 to 16 }
- IF ( temp > 21 ) AND ( temp <= 32 ) THEN
- choice := temp;
- END;
-
- IF (choice > max_icons + 2 ) OR ( choice < 1 ) THEN { if choice }
- choice := old_choice; { illegal }
- { reset it }
- END; { evaluate_choice }
-
-
- { ============ GET CHOICE STARTS HERE =============== }
-
-
- BEGIN
- button := 0; { get rid of old values }
- which1 := 0; { which1 & button }
- which1 := Get_Event( E_Button |
- E_Timer, { want buttons or out }
- $0001, $0001, 1, { left button, down, & }
- 350, { counter for small delay }
- FALSE, 0,0,0,0,
- FALSE, 0,0,0,0,
- message,
- dummy, { no key wanted }
- count, button, { want count & button state }
- mx, my, { do want coordinates }
- dummy ); { no special keys wanted }
-
- IF pop_event = FALSE THEN { throw out choices }
- IF ( button = 1 ) AND ( count = 1 ) THEN { made while busy }
- choice_made := TRUE { clicked ? }
- ELSE
- BEGIN
- choice_made := FALSE; { no, find out x & y }
- Evaluate_Choice; { co-ords of mouse }
- END
- ELSE
- BEGIN
- choice_made := FALSE; { next event not ignored }
- pop_event := FALSE;
- END;
-
- END; { get_choice }
-
-
- PROCEDURE Highlight_Choice_and_Draw_Icon;
-
-
- PROCEDURE Draw_Icon( icon_num : INTEGER );
-
- VAR record_num, count, word, byte, state, s_err, r_err : LONG_INTEGER;
- icon_x, icon_y, draw_of_x, draw_of_y, i : INTEGER;
- temp_char : chr16 ;
-
- BEGIN
- record_num := ( icon_num - 1 ) * 289 + 2 ; { ignore 1st 2 bytes }
- count := record_num;
-
- draw_of_x := 32 * let_x; { x & y of icon on screen }
- draw_of_y := 5 * let_y;
-
- icon_y := 1; { upper right dot of icon }
- icon_x := 1;
-
- Set_Mouse( M_Bee );
- while record_num < count + 286 DO { icon is 578 bytes long }
- BEGIN { get 2 at time }
- s_err := f_Seek( record_num * 2 , PM_data_handle , 0 );
- record_num := record_num + 1;
- r_err := f_read( PM_data_handle , 2 , temp_char );
-
- byte := Ord( temp_char[ 1 ] ) * 256 + Ord( temp_char[ 2 ] );
- word := 32768;
-
- For i := 0 TO 15 DO
- BEGIN
- state := word & byte;
- IF state <> 0 THEN
- BEGIN
- line_color( black );
- icon[ icon_y, icon_x ] := '1';
- line( icon_x + draw_of_x, icon_y + draw_of_y,
- icon_x + draw_of_x, icon_y + draw_of_y );
- END
- ELSE
- BEGIN
- line_color( white );
- icon[ icon_y, icon_x ] := '0';
- line( icon_x + draw_of_x, icon_y + draw_of_y,
- icon_x + draw_of_x, icon_y + draw_of_y );
- END;
- icon_x := icon_x + 1; { icon is 88 by 52 }
- IF icon_x = 89 THEN
- BEGIN
- icon_x := 1;
- icon_y := icon_y +1;
- END;
- word := word DIV 2;
-
- END; { for }
- END; { while }
- Set_Mouse( M_Arrow );
-
- END; { draw_icon }
-
-
- { ====== HIGHLIGHT CHOICE AND DRAW ICON STARTS HERE ======}
-
-
- BEGIN
- Hide_Mouse;
- Get_Coordinates( old_choice );
- Text_Color( black );
- Draw_Mode( 1 ); { rewrite in normal }
- If old_choice > 0 THEN
- Draw_String( pos_x, pos_y, names[ old_choice ] );
-
- Get_Coordinates( choice );
- Draw_String( pos_x , pos_y , ' ' );
- Draw_Mode( 4 ); { reverse video new choice }
- Draw_String( pos_x, pos_y, names[ choice ] );
-
- Draw_Mode( 1 );
- Show_Mouse;
- IF ( choice > 0 ) AND ( choice < max_icons + 1 ) THEN
- Draw_Icon( choice + icon_offset );
-
- END; { highlight_choice_and_draw_icon }
-
-
- PROCEDURE Save_TS_icon;
-
- VAR temp_i : INTEGER;
- t_chr : chr2;
- byt, word, err : LONG_INTEGER;
- no_save, open : BOOLEAN;
-
-
- PROCEDURE Io_Error_Message;
-
- VAR message : str88;
- choice : INTEGER;
-
- BEGIN
- good_name := FALSE;
- message := '[3][ I/O error: | Will you: ][ quit | re-try ]';
-
- choice := Do_Alert( message, 1 );
-
- IF choice = 1 THEN
- no_save := TRUE { drop out of loop }
- ELSE
- no_save := FALSE; { stay in loop }
-
- END; { io_error_message }
-
-
- PROCEDURE Confirm_No_Save;
-
- VAR message : str88;
- choice : INTEGER;
-
- BEGIN
- message := '[3][ Confirm!: ][ quit | save ]';
- choice := Do_Alert( message, 2 );
- IF choice = 1 THEN
- BEGIN
- good_name := TRUE; { allow to fall through good_name }
- no_save := TRUE; { name check but not try to save }
- END;
-
- END; { confirm_no_save }
-
-
- PROCEDURE Write_Byte;
-
- BEGIN
- t_chr[ 1 ] := Chr( byt DIV 256 ); { put high & low bytes }
- t_chr[ 2 ] := Chr( byt MOD 256 ); { in t_char and then }
- err := f_write( TS_data_handle , 2 , t_chr );
- word := 32768; { restore mask and 0 }
- byt := 0; { byt for next go }
-
- END; { write_byte }
-
-
- PROCEDURE Write_Icon;
-
- VAR ix, iy : INTEGER;
-
- BEGIN
- Set_Mouse( M_Bee ); { busy bee while }
- byt := 0; { writing. 0 byt & }
- word := 32768; { initial the mask }
- err := 2; { no error at start! }
- iy := 1;
- WHILE ( err = 2 ) AND
- ( iy <= 52 ) DO { 52 rows }
- BEGIN
- ix := 1;
- WHILE ( err = 2 ) AND
- ( ix <= 88 ) DO { get row. ( 88 ) }
- BEGIN
- IF icon[ iy, ix ] = '1' THEN { if dot 1 then }
- byt := byt + word; { add the bit on }
- word := SHR( word , 1 ); { shift mask right }
- IF word = 0 THEN { if mask zero then }
- Write_Byte; { byte is filled }
- ix := ix + 1;
- END; { ix } { write it! }
- { PM row finished }
- ix := 12; { but TS has more so }
- WHILE ( ix <= 26 ) AND
- (err = 2 ) DO
- BEGIN { tack on zeros to }
- Write_Byte; { fill. ( when drop }
- byt := 0; { from x 1 byte left }
- ix := ix + 1; { write it and rest }
- END; { ix } { write it and rest }
- { are zeros. }
- iy := iy + 1; { if error occurs }
- END; { iy } { will drop out!! }
- no_save := TRUE;
- Set_Mouse( M_Arrow );
-
- END; { write_icon }
-
-
- { ============== SAVE TS ICON BEGINS HERE ================= }
-
-
- BEGIN
- no_save := FALSE; { outer loop to save icon }
- WHILE no_save = FALSE DO
- BEGIN
- good_name := FALSE; { just as sounds }
- open := FALSE; { did try open file? }
-
- WHILE good_name = FALSE DO { inner loop to get name }
- BEGIN
- err := 2; { no write error in case }
- Get_TS_Name; { decide to drop out }
- IF good_name = FALSE THEN
- confirm_no_save { clicked cancel box }
- ELSE
- BEGIN
- Check_Name( 'ICN' ,
- out_filename ,
- good_name ); { is filename good? }
- no_save := quit; { quit flag was borrowed }
- quit := FALSE; { so restore now }
- END;
- END; { while good_name }
-
- IF no_save = FALSE THEN { so do save! }
- BEGIN
- Open_TS_Data( temp_i ); { open file! & set flag }
- open := TRUE;
- END;
- IF ( temp_i >= 0 ) AND
- ( open = TRUE ) THEN { if open & no error }
- Write_Icon { save icon }
- ELSE
- If open = TRUE THEN { do error only if tried open }
- io_error_message;
-
- IF err <> 2 THEN io_error_message; { error on write }
-
- IF ( open = TRUE ) AND
- ( temp_i >= 0 ) THEN { close file }
- err := f_close( TS_data_handle ); { only if opened! }
-
- END; { while no_save }
-
- END; { save_TS_icon }
-
-
- { ============== MENU BEGINS HERE ============= }
-
-
- BEGIN
- Sys_Font_Size( let_x, let_y, pos_x, pos_y );
- icon_offset := 0;
- done := FALSE;
- eof := FALSE;
-
- While done = FALSE DO
- BEGIN
- old_choice := 0;
- Print_menu_title;
- made_choice := FALSE;
- pop_event := TRUE;
- Get_30_Names( max_icons );
- Print_30_Names( max_icons );
- While made_choice = FALSE DO
- BEGIN
-
- Get_Choice( made_choice );
- IF old_choice <> choice THEN
- highlight_choice_and_draw_icon;
-
- END; { while made_choice }
-
- IF choice = max_icons + 1 THEN { wants next screen }
- BEGIN
- made_choice := FALSE;
- icon_offset := icon_offset + 30;
- pop_event := TRUE;
- END
- ELSE
- IF choice = max_icons + 2 THEN { want to quit }
- done := TRUE
- ELSE
- BEGIN
- save_TS_icon; { save then make sure }
- done := FALSE; { repeat loop for in }
- END; { case want more }
-
- END; { while done }
-
- END; { menu }
-
-
-
- { =========== Main Routine Begins Here =========== }
-
-
- BEGIN
- Initialize_Variables;
- quit := FALSE;
- While quit = FALSE do
- BEGIN
- good_name := FALSE;
- While good_name = FALSE DO
- BEGIN
- Get_PM_Name;
- IF good_name = FALSE THEN { CANCEL chosen so }
- BEGIN { check if want to quit. }
- confirm_quit; { TRUE means yes so cycle }
- END { out of this WHILE loop }
- ELSE { and DO NOT go to the }
- check_name( 'SDR' ,
- in_filename ,
- good_name ); { MENU procedure. }
- END; { while } { Otherwise, check for }
- { legal filename. }
-
- IF quit = FALSE THEN
- BEGIN
- Open_PM_File( misc1 );
- Open_PM_Data( misc2 );
- IF (misc1 >= 0) and (misc2 >= 0) THEN { misc contains the }
- menu { handles or errors }
- ELSE
- m_error := F_Close( PM_Name_handle );
- m_error := F_Close( PM_data_handle );
- END;
-
- END; { while }
- good_bye;
-
- END; { main_routine }
-
-
- { MAIN BUSINESS STARTS HERE }
-
- BEGIN
- IF Init_Gem >=0 THEN
- BEGIN
- Vanity; { pre-start messages }
- Screen_Set_Up( window_number ); { open window and clean it }
- Main_Routine; { all the action is here! }
- Close_Window( window_number ); { all done. Close & delete }
- Delete_Window( window_number ); { window and leave things }
- Exit_Gem; { nice and neat - or else! }
- END;
- END.
-